<?php

/**
 * invoice_terms actions.
 *
 * @package    erp-crm
 * @subpackage invoice_terms
 * @author     Milwell H. Sia
 * @version    SVN: $Id: actions.class.php 12479 2008-10-31 10:54:40Z fabien $
 */
class invoice_termsActions extends sfActions
{
 /**
  * Executes index action
  *
  * @param sfRequest $request A request object
  */
  public function executeIndex(sfWebRequest $request)
  {
    $this->listInvoiceTermss = ListInvoiceTermsPeer::doSelect(new Criteria());
    $this->listInvoiceTermsForm = new ListInvoiceTermsForm();
  }
  
  public function executeInsert(sfWebRequest $request){
    $list_invoice_terms = $request->getParameter('list_invoice_terms');
    $list_invoice_terms['iden'] = myStringGenerator::getIden();
    $this->listInvoiceTermss = ListInvoiceTermsPeer::doSelect(new Criteria());
    $this->listInvoiceTermsForm = new ListInvoiceTermsForm();
    $this->listInvoiceTermsForm->bind($list_invoice_terms);
    if($this->listInvoiceTermsForm->isValid()){
      $this->listInvoiceTermsForm->save();
      $this->redirect('invoice_terms/index');
    }
    $this->setTemplate('index');
  }
  
  public function executeEdit(sfWebRequest $request){
    $listInvoiceTerms = ListInvoiceTermsPeer::retrieveByPk($request->getParameter('iden'));
    $this->forward404Unless($listInvoiceTerms);
    $this->listInvoiceTermss = ListInvoiceTermsPeer::doSelect(new Criteria());
    $this->listInvoiceTermsForm = new ListInvoiceTermsForm($listInvoiceTerms);
    $this->setTemplate('index');
  }
  
  public function executeUpdate(sfWebRequest $request){
    $list_invoice_terms = $request->getParameter('list_invoice_terms');
    $listInvoiceTerms = ListInvoiceTermsPeer::retrieveByPk($list_invoice_terms['iden']);
    $this->forward404Unless($listInvoiceTerms);
    $this->listInvoiceTermss = ListInvoiceTermsPeer::doSelect(new Criteria());
    $this->listInvoiceTermsForm = new ListInvoiceTermsForm($listInvoiceTerms);
    $this->listInvoiceTermsForm->bind($request->getParameter('list_invoice_terms'));
    if($this->listInvoiceTermsForm->isValid()){
      $this->listInvoiceTermsForm->save();
      $this->redirect('invoice_terms/index');
    }
    $this->setTemplate('index');
  }
  
  public function executeDelete(sfWebRequest $request){
    $listInvoiceTerms = ListInvoiceTermsPeer::retrieveByPk($request->getParameter('iden'));
    $this->forward404Unless($listInvoiceTerms);
    $listInvoiceTerms->delete();
    $this->redirect('invoice_terms/index');
  }

}
